#include<stdio.h>
int main()
{
    int arr[2][12] = { {0,31,59,90,120,151,181,212,243,273,304,334},
                      {0,31,60,91,121,152,182,213,244,274,305,335} };
    int year, month, day, a = 0, sum;
    scanf("%d %d %d", &year, &month, &day);
    if ((0 == year % 400) || ((0 == year % 4) && (0 != year % 100)))
    {
        a = 1;
    }
    sum = arr[a][month - 1] + day;
    printf("%d", sum);
    return 0;

}